package com.lzx.iteam.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;

/**
 * Created with IntelliJ IDEA.
 * User: danny
 * Date: 13-11-25
 * Time: 上午11:58
 * To change this template use File | Settings | File Templates.
 */
public class MyRelativeView extends RelativeLayout {

    private GetHeightListener mListener;

    private int viewId = 0;
    public void setGetHeightListener(GetHeightListener listener, int viewId){
        mListener = listener;
        this.viewId = viewId;
    }

    public MyRelativeView(Context context) {
        super(context);    //To change body of overridden methods use File | Settings | File Templates.
    }

    public MyRelativeView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);    //To change body of overridden methods use File | Settings | File Templates.
    }

    public MyRelativeView(Context context, AttributeSet attrs) {
        super(context, attrs);    //To change body of overridden methods use File | Settings | File Templates.
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);    //To change body of overridden methods use File | Settings | File Templates.
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        if(changed){
            int height = (b - t) - getPaddingBottom() - getPaddingTop();
            if(mListener != null){
                mListener.getHeight(height);
            }
        }
        super.onLayout(changed, l, t, r, b);    //To change body of overridden methods use File | Settings | File Templates.
    }
}
